Skip to content

Comments

cec: support for explicit control of Cilium Envoy filter injection#5

Open
MitchLewis930 wants to merge 1 commit intopr_045_beforefrom
pr_045_after
Open

cec: support for explicit control of Cilium Envoy filter injection#5
MitchLewis930 wants to merge 1 commit intopr_045_beforefrom
pr_045_after

Conversation

@MitchLewis930
Copy link

PR_045

Currently, the Cilium Envoy network- and L7 filters are always automatically
injected when the CiliumEnvoyConfig is used for L7LB (parameter `isL7LB` - that
is set to true when `Spec.Services` are defined on the CEC).

This commit adds the possibility for a more explicit configuration of this
behaviour by adding the annotation `cec.cilium.io/inject-cilium-filters`.

If the annotation is present on the `CiliumEnvoyConfig` it is used to decide
whether Cilium Envoy filters should be automatically injected or not.

Signed-off-by: Marco Hofstetter <marco.hofstetter@isovalent.com>
@MitchLewis930 MitchLewis930 requested a review from Copilot January 31, 2026 01:11
Copy link

Copilot AI left a comment

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Pull request overview

This PR adds support for explicit control of Cilium Envoy filter injection in CiliumEnvoyConfig resources through a new annotation, decoupling filter injection from L7 load balancing configuration.

Changes:

  • Introduces cec.cilium.io/inject-cilium-filters annotation to explicitly control filter injection
  • Refactors parseResources to accept separate injectCiliumEnvoyFilters parameter instead of inferring from isL7LB
  • Updates all test cases to accommodate the new parameter signature

Reviewed changes

Copilot reviewed 6 out of 6 changed files in this pull request and generated 3 comments.

Show a summary per file
File Description
pkg/annotation/k8s.go Adds CECPrefix constant and CECInjectCiliumFilters annotation definition; reformats CiliumPrefixRegex variable declaration
pkg/ciliumenvoyconfig/cec_manager.go Implements injectCiliumEnvoyFilters function and integrates it into resource parsing calls
pkg/ciliumenvoyconfig/cec_manager_test.go Adds comprehensive test coverage for injectCiliumEnvoyFilters function and updates existing test calls
pkg/ciliumenvoyconfig/cec_resource_parser.go Updates parseResources signature to accept injectCiliumEnvoyFilters parameter and refactors filter injection logic
pkg/ciliumenvoyconfig/cec_resource_parser_test.go Updates all parseResources calls with new parameter and adds test for filter injection behavior
pkg/ciliumenvoyconfig/exp_reflector.go Updates registerCECReflector to pass injectCiliumEnvoyFilters result to parseResources

💡 Add Copilot custom instructions for smarter, more guided reviews. Learn how to get started.

cecObjectMeta.GetName(),
cecSpec.Resources,
len(cecSpec.Services) > 0,
len(cecSpec.Services) > 0,
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

This line should call injectCiliumEnvoyFilters(&cecObjectMeta, cecSpec) instead of duplicating the condition len(cecSpec.Services) > 0. The current code bypasses the annotation-based override logic and hardcodes the old behavior, making the new feature non-functional in the addCiliumEnvoyConfig path.

Suggested change
len(cecSpec.Services) > 0,
injectCiliumEnvoyFilters(&cecObjectMeta, cecSpec),

Copilot uses AI. Check for mistakes.
// added to all non-internal Listeners. In addition, the info gets passed to the Envoy Cilium BPF Metadata listener filter on all Listeners.
// - `isL7LB` defines whether these resources are used for L7 loadbalancing. If `true`, the info gets passed to
// the Envoy Cilium BPF Metadata listener filter on all Listeners.
// - `injecCiliumEnvoyFilters` defines whether the Envoy Cilium Network- and L7 filters should always be added to all non-internal Listeners.
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

Corrected spelling of 'injecCiliumEnvoyFilters' to 'injectCiliumEnvoyFilters'.

Suggested change
// - `injecCiliumEnvoyFilters` defines whether the Envoy Cilium Network- and L7 filters should always be added to all non-internal Listeners.
// - `injectCiliumEnvoyFilters` defines whether the Envoy Cilium Network- and L7 filters should always be added to all non-internal Listeners.

Copilot uses AI. Check for mistakes.
Comment on lines 204 to +205

var (
// CiliumPrefixRegex is a regex matching Cilium specific annotations.
CiliumPrefixRegex = regexp.MustCompile(`^([A-Za-z0-9]+\.)*cilium.io/`)
CECInjectCiliumFilters = CECPrefix + "/inject-cilium-filters"
Copy link

Copilot AI Jan 31, 2026

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

The blank line at 204 creates inconsistent spacing in the constant declarations block. Consider removing it to maintain consistency with the surrounding code formatting.

Copilot uses AI. Check for mistakes.
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment

Labels

None yet

Projects

None yet

Development

Successfully merging this pull request may close these issues.

2 participants